package utils;

import java.security.MessageDigest;



public class Encryptor 
{
	
	private static String algorithm = "MD5";
	
	public static String encryptPW(String password)
	{
		byte[] plainText = password.getBytes();
		MessageDigest md = null;
		try
		{
			md = MessageDigest.getInstance(algorithm);
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		md.reset();
		md.update(plainText);
		byte[] encodedPW = md.digest();
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < encodedPW.length; i++) 
		{
			if ((encodedPW[i] & 0xff) < 0x10) 
			{
				sb.append("0");
			}
			sb.append(Long.toString(encodedPW[i] & 0xff, 16));
		}
		return sb.toString();
	}
	

}
